<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.waimai.db.entity.Admin"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>系统登录</title>
    <link href="${pageContext.request.contextPath }/css/login.css" rel="stylesheet" rev="stylesheet" type="text/css" media="all" />
    <link href="${pageContext.request.contextPath }/css/demo.css" rel="stylesheet" rev="stylesheet" type="text/css" media="all" />
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery1.42.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.SuperSlide.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/Validform_v5.3.2_min.js"></script>

    <script>
        $(function(){


            $("#username").focusout(function(){
                var username = $(this).val();                
                if(username==""){
                    $(".error-box").text('账号不能为空！');
                }else{
                	$(".error-box").text('');
                }                
            });


            $("#password").focusout(function(){
                var password = $(this).val();
                var reg=/^[a-zA-Z0-9]\w{5,17}$/;                                               
                if(password==""){
                    $(".error-box").text('密码不能为空！');
                }else if(!reg.test(password)){
                	$(".error-box").text('注意:长度在6~18之间，只能包含字母、数字和下划线！');
                }else{
                	$(".error-box").text('');
                }
            });


            $("#yzm").focus(function(){
                var username = $(this).val();
                if(username=='输入验证码'){
                    $(this).val('');
                }
            });
			
            $(".btn-login").click(function(){
          	  //post验证
              var username = $("#username").val().trim();  
              var password = $("#password").val().trim();  
              var url = "${pageContext.request.contextPath }/admin/checkLogin";              
              var params={adminName:username,password:password};
              $.post(url,params, function(data, status){
              	if (status=="success") {
              		if (data != "") {
              				var rank = data.rank;
              				if (rank == "管理员") {
                  				window.location.href="${pageContext.request.contextPath }/admin/toIndex";
							}else if (rank == "普通商家") {
								window.location.href="${pageContext.request.contextPath }/admin/toCommon";
							}else{
								window.location.href="${pageContext.request.contextPath }/admin/toError";
							}
              				
					}else{
	    				$(".error-box").text("用户名或密码不正确！");
	    			}                		
  				}
              });
              return false;
          	
          });

        });

		
    </script>


</head>

<body>

<div class="header">
    <h1 class="headerLogo"><a title="后台管理系统" target="_blank" href="#"><img alt="logo" src="${pageContext.request.contextPath }/images/logo.gif"></a></h1>

</div>
<div class="dividen"></div>
<div class="banner">
    <div class="banner-left">
        <img src="${pageContext.request.contextPath }/images/banner_left.png" alt=""/>
    </div>
    <div class="login-aside">
        <div id="o-box-up"></div>
        <div id="o-box-down"  style="table-layout:fixed;">
            <div class="error-box"></div>
            <form class="registerform" action="demo/ajax_post.jsp">
                <div class="fm-item">
                    <label for="logonId" class="form-label">MISS系统登陆：</label>
                    <input type="text" placeholder="输入账号" maxlength="100" id="username" class="i-text" ajaxurl="demo/valid.jsp"  datatype="s6-18" errormsg="用户名至少6个字符,最多18个字符！"  >
                    <div class="ui-form-explain"></div>
                </div>

                <div class="fm-item">
                    <label for="logonId" class="form-label">登陆密码：</label>
                    <input type="password" placeholder="输入密码" maxlength="100" id="password" class="i-text" datatype="*6-16" nullmsg="请设置密码！" errormsg="密码范围在6~16位之间！">
                    <div class="ui-form-explain"></div>
                </div>

                <div class="fm-item pos-r">
                    <label for="logonId" class="form-label">验证码</label>
                    <input type="text" value="输入验证码" maxlength="100" id="yzm" class="i-text yzm" nullmsg="请输入验证码！" >
                    <div class="ui-form-explain"><img src="${pageContext.request.contextPath }/images/yzm.jpg" class="yzm-img" /></div>
                </div>

                <div class="fm-item">
                    <label for="logonId" class="form-label"></label>
                    <input type="submit" value="" tabindex="4" id="btn-login" class="btn-login">
                    <div class="ui-form-explain"></div>
                </div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">jQuery(".banner").slide({ titCell:".hd ul", mainCell:".bd ul", effect:"fold",  autoPlay:true, autoPage:true, trigger:"click" });</script>

<div class="banner-shadow"></div>

<div class="footer">
    <p>©2015 美团网团购 meituan.com 京ICP证070791号 京公网安备11010502025545号 电子公告服务规则</p>
</div>

</body>
</html>
